package com.yand.thinkingInJava.thinkingInJava21.daemon;

import java.util.concurrent.TimeUnit;


/**
 * 守护线程中 当其他的线程全部结束后，守护线程直接消除，无论守护线程执行到哪一步，哪怕是 finally 关键词也不行
 */
class ADDaemon implements Runnable{

    @Override
    public void run() {
try{
        System.out.println("This is Daemon Thread");
        TimeUnit.MILLISECONDS.sleep(2000);
         System.out.println("hahah...");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
          System.out.println("finally...");
        }


    }
}

public class DaemonDontRunfanlly {

    public static void main(String [] args){
        Thread t = new Thread(new ADDaemon());
        t.setDaemon(true);
        t.start();





    }


}
